package com.jyy.prefabricated.service;

import com.jyy.prefabricated.entity.CertificateType;
import com.jyy.prefabricated.exception.CustomException;
import com.jyy.prefabricated.mapper.CertificateTypeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @version 1.0.0
 * @author: zjj
 */

@Service
public class CertificateTypeService {

    @Autowired
    private CertificateTypeMapper certificateTypeMapper;


    public Integer insert(CertificateType certificateType){
        certificateTypeMapper.insert(certificateType);
        return certificateType.getId();
    }


    public int update(CertificateType certificateType){
        if(certificateType.getId() == null){
            throw new CustomException("参数id不能为空");
        }
        return certificateTypeMapper.updateByPrimaryKeySelective(certificateType);
    }


    public int delete(Integer id){
        return certificateTypeMapper.deleteByPrimaryKey(id);
    }

    public CertificateType selectById(Integer id){
        return certificateTypeMapper.selectByPrimaryKey(id);
    }

    public List<CertificateType> selectAll(){
        return certificateTypeMapper.selectAll();
    }
}
